<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
<title>Application Client - The Java EE 5 Tutorial</title>
<meta name="robots" content="index,follow">
<meta name="robots" content="index,follow">
<meta name="date" content="2008-10-01">
<link rel="stylesheet" type="text/css" href="css/default.css">
<link rel="stylesheet" type="text/css" href="css/ipg.css">
<link rel="stylesheet" type="text/css" href="css/j5eetutorial.css">
</head>

<body>

<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody>
   <tr valign="top">
      <td><p class="toc level1"><a href="docinfo.html">Document Information</a></p>
<p class="toc level1 tocsp"><a href="gexaf.html">Preface</a></p>
<p class="toc level1 tocsp"><a href="gfirp.html">Part&nbsp;I&nbsp;Introduction</a></p>
<p class="toc level2"><a href="bnaaw.html">1.&nbsp;&nbsp;Overview</a></p>
<p class="toc level2"><a href="gfiud.html">2.&nbsp;&nbsp;Using the Tutorial Examples</a></p>
<p class="toc level1 tocsp"><a href="bnadp.html">Part&nbsp;II&nbsp;The Web Tier</a></p>
<p class="toc level2"><a href="bnadr.html">3.&nbsp;&nbsp;Getting Started with Web Applications</a></p>
<p class="toc level2"><a href="bnafd.html">4.&nbsp;&nbsp;Java Servlet Technology</a></p>
<p class="toc level2"><a href="bnagx.html">5.&nbsp;&nbsp;JavaServer Pages Technology</a></p>
<p class="toc level2"><a href="bnajo.html">6.&nbsp;&nbsp;JavaServer Pages Documents</a></p>
<p class="toc level2"><a href="bnakc.html">7.&nbsp;&nbsp;JavaServer Pages Standard Tag Library</a></p>
<p class="toc level2"><a href="bnalj.html">8.&nbsp;&nbsp;Custom Tags in JSP Pages</a></p>
<p class="toc level2"><a href="bnaon.html">9.&nbsp;&nbsp;Scripting in JSP Pages</a></p>
<p class="toc level2"><a href="bnaph.html">10.&nbsp;&nbsp;JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="bnaqz.html">11.&nbsp;&nbsp;Using JavaServer Faces Technology in JSP Pages</a></p>
<p class="toc level2"><a href="bnatx.html">12.&nbsp;&nbsp;Developing with JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="bnavg.html">13.&nbsp;&nbsp;Creating Custom UI Components</a></p>
<p class="toc level2"><a href="bnawo.html">14.&nbsp;&nbsp;Configuring JavaServer Faces Applications</a></p>
<p class="toc level2"><a href="bnaxu.html">15.&nbsp;&nbsp;Internationalizing and Localizing Web Applications</a></p>
<p class="toc level1 tocsp"><a href="bnayk.html">Part&nbsp;III&nbsp;Web Services</a></p>
<p class="toc level2"><a href="bnayl.html">16.&nbsp;&nbsp;Building Web Services with JAX-WS</a></p>
<p class="toc level2"><a href="bnazf.html">17.&nbsp;&nbsp;Binding between XML Schema and Java Classes</a></p>
<p class="toc level2"><a href="bnbdv.html">18.&nbsp;&nbsp;Streaming API for XML</a></p>
<p class="toc level2"><a href="bnbhf.html">19.&nbsp;&nbsp;SOAP with Attachments API for Java</a></p>
<p class="toc level1 tocsp"><a href="bnblr.html">Part&nbsp;IV&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="bnbls.html">20.&nbsp;&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="bnbnb.html">21.&nbsp;&nbsp;Getting Started with Enterprise Beans</a></p>
<p class="toc level2"><a href="bnboc.html">22.&nbsp;&nbsp;Session Bean Examples</a></p>
<p class="toc level2"><a href="bnbpk.html">23.&nbsp;&nbsp;A Message-Driven Bean Example</a></p>
<p class="toc level1 tocsp"><a href="bnbpy.html">Part&nbsp;V&nbsp;Persistence</a></p>
<p class="toc level2"><a href="bnbpz.html">24.&nbsp;&nbsp;Introduction to the Java Persistence API</a></p>
<p class="toc level2"><a href="bnbrl.html">25.&nbsp;&nbsp;Persistence in the Web Tier</a></p>
<p class="toc level2"><a href="bnbrs.html">26.&nbsp;&nbsp;Persistence in the EJB Tier</a></p>
<p class="toc level2"><a href="bnbtg.html">27.&nbsp;&nbsp;The Java Persistence Query Language</a></p>
<p class="toc level1 tocsp"><a href="bnbwi.html">Part&nbsp;VI&nbsp;Services</a></p>
<p class="toc level2"><a href="bnbwj.html">28.&nbsp;&nbsp;Introduction to Security in the Java EE Platform</a></p>
<p class="toc level2"><a href="bnbyk.html">29.&nbsp;&nbsp;Securing Java EE Applications</a></p>
<p class="toc level2"><a href="bncas.html">30.&nbsp;&nbsp;Securing Web Applications</a></p>
<p class="toc level2"><a href="bncdq.html">31.&nbsp;&nbsp;The Java Message Service API</a></p>
<p class="toc level2"><a href="bncgv.html">32.&nbsp;&nbsp;Java EE Examples Using the JMS API</a></p>
<p class="toc level2"><a href="bncih.html">33.&nbsp;&nbsp;Transactions</a></p>
<p class="toc level2"><a href="bncjh.html">34.&nbsp;&nbsp;Resource Connections</a></p>
<p class="toc level2"><a href="bncjx.html">35.&nbsp;&nbsp;Connector Architecture</a></p>
<p class="toc level1 tocsp"><a href="bnckn.html">Part&nbsp;VII&nbsp;Case Studies</a></p>
<p class="toc level2"><a href="bncko.html">36.&nbsp;&nbsp;The Coffee Break Application</a></p>
<p class="toc level2"><a href="bnclz.html">37.&nbsp;&nbsp;The Duke's Bank Application</a></p>
<p class="toc level3"><a href="bncma.html">Overview of the Duke's Bank Application</a></p>
<p class="toc level3"><a href="bncmb.html">Enterprise Beans</a></p>
<p class="toc level4"><a href="bncmb.html#bncmc">Session Beans</a></p>
<p class="toc level5"><a href="bncmb.html#bncmd">The <tt>AccountControllerBean</tt> Session Bean</a></p>
<p class="toc level5"><a href="bncmb.html#bncme">The <tt>CustomerControllerBean</tt> Session Bean</a></p>
<p class="toc level5"><a href="bncmb.html#bncmf">The <tt>TxControllerBean</tt> Session Bean</a></p>
<p class="toc level4 tocsp"><a href="bncmb.html#bncmg">Java Persistence Entities</a></p>
<p class="toc level4"><a href="bncmb.html#bncmh">Helper Classes</a></p>
<p class="toc level4"><a href="bncmb.html#bncmj">Database Tables</a></p>
<p class="toc level5"><a href="bncmb.html#bncmk">Tables Representing Business Entities</a></p>
<p class="toc level4 tocsp"><a href="bncmb.html#bncmm">Protecting the Enterprise Beans</a></p>
<div class="onpage">
<p class="toc level3 tocsp"><a href="">Application Client</a></p>
<p class="toc level4"><a href="#bncmp">The Classes and Their Relationships</a></p>
<p class="toc level4"><a href="#bncmq"><tt>BankAdmin</tt> Class</a></p>
<p class="toc level5"><a href="#bncmr">The <tt>BankAdmin</tt> Constructor</a></p>
<p class="toc level5"><a href="#bncms">Class Methods</a></p>
</div>
<p class="toc level3 tocsp"><a href="bncmt.html">Web Client</a></p>
<p class="toc level4"><a href="bncmt.html#bncmw">Design Strategies</a></p>
<p class="toc level4"><a href="bncmt.html#bncmx">Client Components</a></p>
<p class="toc level4"><a href="bncmt.html#bncmy">Request Processing</a></p>
<p class="toc level4"><a href="bncmt.html#bncmz">Protecting the Web Client Resources</a></p>
<p class="toc level3 tocsp"><a href="bncna.html">Building, Packaging, Deploying, and Running the Duke's Bank Application</a></p>
<p class="toc level4"><a href="bncna.html#bncnb">Setting Up the Servers</a></p>
<p class="toc level5"><a href="bncna.html#bncnc">Starting the Application Server</a></p>
<p class="toc level5"><a href="bncna.html#bncnd">Creating the Bank Database in NetBeans IDE</a></p>
<p class="toc level5"><a href="bncna.html#bncne">Creating the Bank Database Using Ant</a></p>
<p class="toc level5"><a href="bncna.html#bncnf">Adding Users and Groups to the File Realm</a></p>
<p class="toc level4 tocsp"><a href="bncna.html#bncnh">Building, Packaging, and Deploying Duke's Bank Using NetBeans IDE</a></p>
<p class="toc level4"><a href="bncna.html#bncni">Building, Packaging, and Deploying Duke's Bank Using Ant</a></p>
<p class="toc level4"><a href="bncna.html#bncnj">Running the Duke's Bank Application Client Using NetBeans IDE</a></p>
<p class="toc level4"><a href="bncna.html#bncnk">Running the Duke's Bank Application Client Using Ant</a></p>
<p class="toc level4"><a href="bncna.html#bncnm">Running the Duke's Bank Web Client</a></p>
<p class="toc level1 tocsp"><a href="gexbq.html">Part&nbsp;VIII&nbsp;Appendixes</a></p>
<p class="toc level2"><a href="bncno.html">A.&nbsp;&nbsp;Java Encoding Schemes</a></p>
<p class="toc level2"><a href="bncnq.html">B.&nbsp;&nbsp;Preparation for Java EE Certification Exams</a></p>
<p class="toc level2"><a href="bncnt.html">C.&nbsp;&nbsp;About the Authors</a></p>
<p class="toc level1 tocsp"><a href="idx-1.html">Index</a></p>
</td>
      <td width="10px">&nbsp;</td>
      <td width="705px">
         <div class="header">
             <div class="header-links-top">
                 <a href="http://java.sun.com">java.sun.com</a> |
                 <a href="http://docs.sun.com/">docs.sun.com</a><br>
             </div> 
             <img src="graphics/tutorialBanner.gif" width="704" height="120" alt="The Java&trade; EE 5 Tutorial"/>
             <div class="header-links">
	         <a href="index.html">Home</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/download.html">Download</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/JavaEETutorial.pdf">PDF</a> |
                 <a href="http://java.sun.com/javaee/5/docs/api/index.html">API</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/faq.html">FAQ</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/search.html">Search</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/sendusmail.html">Feedback</a> |
                 <a href="http://java.sun.com/javaee/5/docs/tutorial/information/history.html">History</a>
             </div>
             <div class="navigation">
                 <a href="bncmb.html"><img style="padding-right: 3px" src="graphics/leftButton.gif" border="0"></a>
                 <a href="sjsaseej2eet.html"><img style="padding-right: 3px" src="graphics/upButton.gif" border="0"></a>
                 <a href="bncmt.html"><img style="padding-left: 3px" src="graphics/rightButton.gif" border="0"></a>
             </div>
         </div>

	 <div class="maincontent">      	 
             

<a name="bncmn"></a><h3>Application Client</h3>
<p><a name="indexterm-3170"></a><a name="indexterm-3171"></a>Sometimes, enterprise applications use a stand-alone client application for handling tasks such as system
or application administration. For example, the Duke&rsquo;s Bank application uses an application client
to administer customers and accounts. This capability is useful in the event that
the site becomes inaccessible for any reason or if a customer prefers to
communicate things such as changes to account information by phone.</p><p>The application client shown in <a href="#bncmo">Figure&nbsp;37-3</a> handles basic customer and account administration
for the banking application through a Swing user interface. The bank administrator can
perform any of the following functions on the respective tabs.</p><a name="bncmo"></a><h6>Figure&nbsp;37-3 Application Client</h6><img src="figures/dukesbank-appClientCustomer.gif" alt="Screenshot of the Duke's Bank application client for the application admin." width="551" height="642"></img><p>Customer Info tab:</p>
<ul><li><p>View customer information</p></li>
<li><p>Add a new customer to the database</p></li>
<li><p>Update customer information</p></li>
<li><p>Remove a customer</p></li>
<li><p>Find a customer&rsquo;s ID</p></li></ul>
<p>Account administration:</p>
<ul><li><p>Create a new account</p></li>
<li><p>Add a new customer to an existing account</p></li>
<li><p>Remove a customer from an existing account</p></li>
<li><p>View account information</p></li>
<li><p>Remove an account from the database</p></li></ul>
<p>Error and informational messages appear in the bottom under <tt>Messages</tt>.</p>

<a name="bncmp"></a><h4>The Classes and Their Relationships</h4>
<p><a name="indexterm-3172"></a><a name="indexterm-3173"></a>The source code for the application client is in the following directory:</p><pre><tt></tt><i>tut-install</i><tt>/javaeetutorial5/examples/dukesbank/dukesbank-appclient/src/java/com/sun/tutorial/ javaee/dukesbank/client/</tt></pre><p>The application client is consists of a single class: <tt>BankAdmin</tt>.</p>

<a name="bncmq"></a><h4><tt>BankAdmin</tt> Class</h4>
<p><a name="indexterm-3174"></a>The <tt>BankAdmin</tt> class, which creates the user interface, is a Swing class that
provides action methods that are called when certain events occur in the application,
and methods that call the controller session beans. It was created using the
NetBeans IDE Swing editor, Matisse.</p>
<hr><p><b>Note - </b>Although  <tt>BankAdmin</tt> was written using NetBeans IDE, you do not need to
have NetBeans installed in order to run the application. If you want to
alter the user interface, however, you do need to use NetBeans IDE.</p>
<hr>


<a name="bncmr"></a><h5>The <tt>BankAdmin</tt> Constructor</h5>
<p>The <tt>BankAdmin</tt> constructor creates the initial user interface, which consists of a menu
bar, two tabs, and a message pane, by calling the <tt>initComponents</tt> method. The
menu bar contains the standard File and Edit menus, the left tab is
for viewing and updating customer information, the right tab is for viewing and
updating account information, and the message pane contains a message area.</p><p>The <tt>initComponents</tt> method is automatically generated by NetBeans IDE. It creates all the
user interface elements visible in <tt>BankAdmin</tt>.</p>

<a name="bncms"></a><h5>Class Methods</h5>
<p>The <tt>BankAdmin</tt> class provides methods that other objects call when they need to
update the user interface. These methods are as follows:</p>
<ul><li><p><tt>setCustomerTextFields</tt>: When true enables the user to enter or change information in the customer tab. When false, the fields are disabled.</p></li>
<li><p><tt>fillCustomerTextFields</tt>: Uses a <tt>CustomerDetails</tt> object to display customer information in the customer tab</p></li>
<li><p><tt>clearCustomerTextFields</tt>: Clears the contents of the customer fields in the customer tab</p></li>
<li><p><tt>setAccountTextFields</tt>: When true enables the user to enter or change information in the account tab. When false, the fields are disabled.</p></li>
<li><p><tt>fillAccountTextFields</tt>: Uses an <tt>AccountDetails</tt> object to display account information in the account tab</p></li>
<li><p><tt>clearAccountTextFields</tt>: Clears the contents of the account fields in the account tab</p></li>
<li><p><tt>resetAll</tt>: Calls <tt>setCustomerTextFields</tt> and <tt>setAccountFields</tt>, setting all the fields to disabled</p></li></ul>
<p>The following methods interact with the controller session beans to create and update
customer and account information:</p>
<ul><li><p><tt>createAccount</tt>: uses an <tt>AccountDetails</tt> object to create a new account</p></li>
<li><p><tt>updateAccount</tt>: uses an <tt>AccountDetails</tt> object to update an account information</p></li>
<li><p><tt>createCustomer</tt>: uses a <tt>CustomerDetails</tt> object to create a new customer</p></li>
<li><p><tt>updateCustomer</tt>: uses a <tt>CustomerDetails</tt> object to update a customer&rsquo;s information</p></li></ul>
<p>The <tt><i>UI-element</i>MouseReleased</tt> methods are linked to the GUI controls in <tt>BankAdmin</tt>. They call the
previous methods to enable/disable the GUI fields, and create/update accounts and customers.</p>
         </div>
         <div class="navigation">
             <a href="bncmb.html"><img style="padding-right: 3px" src="graphics/leftButton.gif" border="0"></a>
             <a href="sjsaseej2eet.html"><img style="padding-right: 3px" src="graphics/upButton.gif" border="0"></a>
             <a href="bncmt.html"><img style="padding-left: 3px" src="graphics/rightButton.gif" border="0"></a>
         </div>

         <div class="copyright">
      	    <p>The material in The Java&trade; EE 5 Tutorial is <a href='docinfo.html'>copyright</a>-protected and may not be published in other works without express written permission from Sun Microsystems.</p>
      	 </div>

      </td>
   </tr>
</tbody>
</table>
</body>
</html>

